package com.frank.code_notes.C02_LinkedList;

import cn.hutool.core.lang.Console;
import com.frank.utils.DoublyListNode;
import com.frank.utils.MyDoublyLinkedList;
import com.frank.utils.MyLinkedList;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;

/**
 * @Description todo 707.设计链表
 * @Author zhoujr
 * @Data 2024/11/23 14:32
 */
public class L707DesignLinkedList {

    public static void main(String[] args) {
        // 单向链表
        MyLinkedList myLinkedList = new MyLinkedList();
        myLinkedList.addAtHead(1);
        myLinkedList.addAtTail(3);
        myLinkedList.addAtIndex(1, 2);    // 链表变为 1->2->3
        Console.log(myLinkedList.get(1));           // 返回 2
        myLinkedList.deleteAtIndex(1);              // 现在，链表变为 1->3
        Console.log(myLinkedList.get(1));
        // 双向链表
        MyDoublyLinkedList doublyLinkedList = new MyDoublyLinkedList();
        doublyLinkedList.addAtHead(1);
        doublyLinkedList.addAtTail(3);
        doublyLinkedList.addAtIndex(1, 2);    // 链表变为 1->2->3
        Console.log(doublyLinkedList.get(1));           // 返回 2
        doublyLinkedList.deleteAtIndex(1);              // 现在，链表变为 1->3
        Console.log(doublyLinkedList.get(1));
    }

}
